package com.vvkee.office.controller;

import com.vvkee.office.service.FileService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletResponse;

@Controller
@Slf4j
public class FileController {

	@Autowired
	private FileService fileService;

	@GetMapping
	@ResponseBody
	public String index() throws Exception {
		return "index";
	}

	@GetMapping("/test")
	@ResponseBody
	public String test() throws Exception {
		return "/test";
	}

	@GetMapping("/preview")
	public void onlinePreview(@RequestParam("url") String url, HttpServletResponse response) throws Exception {
		log.info("url is {}", url);
		fileService.onlinePreview(url, response);
	}
}
